{% extends 'bugs/base.html' %}
{% block content %}
{#    <nav class="navbar navbar-inverse navbar-fixed-top">#}
{#        <div class="container">#}
{#            <div class="navbar-header">#}
{#                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"#}
{#                        aria-expanded="false" aria-controls="navbar">#}
{#                    <span class="sr-only">Toggle navigation</span>#}
{#                    <span class="icon-bar"></span>#}
{#                    <span class="icon-bar"></span>#}
{#                    <span class="icon-bar"></span>#}
{#                </button>#}
{#                <a class="navbar-brand">Software Afair Management System</a>#}
{#            </div>#}
{#            {% if login_user != None %}#}
{#                <div id="navbar" class="navbar-collapse collapse">#}
{#                <ul class="nav navbar-nav navbar-right">#}
{##}
{#                <li><a href="">Welcome, 您好！{{ login_user }} </a></li>#}
{#                {% if authority == 'admin' %}#}
{#                    <li class="dropdown">#}
{#                        <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">管理#}
{#                            <span class="caret"></span></button>#}
{#                            <ul>#}
{#                            <li><a href="{% url 'bugs:project' %}">项目管理</a></li>#}
{##}
{#                            <li>#}
{#                                <a class="dropdown-toggle" data-toggle="dropdown">人員管理<span#}
{#                                        class="glyphicon glyphicon-menu-down" aria-hidden="true"></span></a>#}
{#                                <ul class="dropdown-menu" role="menu">#}
{#                                    <li>#}
{#                                        <a href="{% url 'bugs:add_user' %}">增加用戶</a>#}
{#                                    </li>#}
{#                                    <li>#}
{#                                        <a href="{% url 'bugs:delete_user' %}">刪除用戶</a>#}
{#                                    </li>#}
{#                                    <li>#}
{#                                        <a href="{% url 'bugs:update_user' %}">修改用戶</a>#}
{#                                    </li>#}
{#                                </ul>#}
{#                            </li>#}
{#                        </ul>#}
{#                    </li>#}
{#                {% endif %}#}
{#            {% endif %}#}
{#            <li>#}
{#                <a href="{% url 'bugs:logout' %}?next=/">#}
{#                    Log out#}
{#                </a>#}
{#            </li>#}
{#            </ul>#}
{#            </div><!--/.navbar-collapse -->#}
{#        </div>#}
{#    </nav>#}
    <div class="container">
        <div align="right">
            <a href="{% url 'bugs:new_demand' %} " class="btn btn-primary btn-sm" role="button">新 需求提报</a>
            <a href="{% url 'bugs:new_bug' %}" class="btn btn-primary btn-sm" role="button">现有 bug提报</a>

        </div>
        <br>
        <div class="panel panel-default">
            <!-- Default panel contents -->
            <div class="panel-heading">
                <input class="btn btn-primary btn-sm" type="button" id="id_bug" onclick="" value="Bug list"/>
                <input class="btn btn-primary btn-sm" type="button" id="id_demand" onclick="" value="Demand list"/>
            </div>

            <div class="panel-body">
                <table class="table" id="t2" style="display: none">
                    <thead>
                    <tr>
                        <th>序号</th>
                        <th>专案</th>
                        <th>Team</th>

                        <th>状态</th>

                        <th>紧急程度</th>
                        {% if authority != 'user' %}
                            <th>难度</th>
                        {% endif %}
                        <th id='description' style="width: 200px">详情</th>
                        <th>创建日期</th>
                        <th>预计完成时间</th>

                        <th>完成日期</th>


                        {% if authority != 'user' %}
                            <th>花费时长</th>
                        {% endif %}
                        <th>发起人</th>
                        <th>发起人分机</th>
                        <th>发起人邮箱</th>

                        <th>受理人</th>
                        <th>受理人分机</th>
                        <th>受理人邮箱</th>

                        <th>最后修改人</th>
                        <th>最后修改日期</th>

                    </tr>
                    </thead>
                    <tbody>
                    {% for demand in demand_message %}
                        <tr>
                            <td>{{ demand.id }}</td>

                            <td><a id="{{ demand.id }}" onclick="go_demand(this)"
                                   style="cursor: pointer">{{ demand.name }}</a>
                            </td>
                            <td>{{ demand.team }}</td>
                            <td>{{ demand.state }}</td>
                            <td>{{ demand.level }}</td>
                            {% if authority != 'user' %}
                                <td>{{ demand.difficult }}</td>
                            {% endif %}
                            <td>{{ demand.description }}</td>
                            <!--# 创建时间-->
                            <td>{{ demand.create_time | date:"Y-m-d H:i:s" }}</td>
                            <!--# 预计完成时间-->
                            <td>{{ bugs.estime | date:"Y-m-d " }}</td>

                            <!--# 完成时间-->
                            {% if demand.state == '已完成' %}
                                <td>{{ demand.success_time | date:"Y-m-d H:i:s" }}</td>
                            {% else %}
                                <td></td>
                            {% endif %}
                            <!--#　完成花费时长-->
                            {% if authority != 'user' %}
                                {% if demand.success_time != 'null' %}
                                    <td>{{ demand.days }}</td>
                                {% else %}
                                    <td></td>
                                {% endif %}
                            {% endif %}
                            <td>{{ demand.owner_c_name }}</td>
                            <td>{{ demand.owner_phone }}</td>
                            <td>{{ demand.owner_email }}</td>
                            <td>{{ demand.assignee_c_name }}</td>
                            <td>{{ demand.assignee_phone }}</td>
                            <td>{{ demand.assignee_email }}</td>
                            <td>{{ demand.modify_bug_user }}</td>
                            <!--# 最后修改时长-->
                            <td>{{ demand.modify_time | date:"Y-m-d H:i:s" }}</td>

                        </tr>
                    {% endfor %}
                    </tbody>
                </table>

                <!-- Table bug_list-->
                <table class="table" id="t1">
                    <thead>
                    <tr>
                        <th>序号</th>
                        <th>专案</th>
                        <th>Team</th>
                        <th>版本</th>
                        <th>状态</th>
                        <th>影响程度</th>
                        <th>紧急程度</th>
                        {% if authority != 'user' %}
                            <th>难度</th>
                        {% endif %}
                        <th id='description' style="width: 200px">详情</th>
                        <th>创建日期</th>
                        <th>预计完成时间</th>

                        <th>完成日期</th>


                        {% if authority != 'user' %}
                            <th>花费时长</th>
                        {% endif %}
                        <th>发起人</th>
                        <th>发起人分机</th>
                        <th>发起人邮箱</th>

                        <th>受理人</th>
                        <th>受理人分机</th>
                        <th>受理人邮箱</th>

                        <th>最后修改人</th>
                        <th>最后修改日期</th>

                    </tr>
                    </thead>
                    <tbody>

                    {% for bugs in bugs_message %}
                        <tr>
                            <td>{{ bugs.id }}</td>
                            {% if bugs.project_type %}
                                <td><a id="{{ bugs.id }}" onclick="go(this)" style="cusrsor:pointer"
                                >{{ bugs.project }}--{{ bugs.project_type }}</a></td>
                            {% else %}
                                <td><a id="{{ bugs.id }}" onclick="go(this)" style="cusrsor:pointer"
                                >{{ bugs.project }}</a></td>
                            {% endif %}
                            <td>{{ bugs.team }}</td>
                            <td>{{ bugs.version }}</td>
                            <td>{{ bugs.state }}</td>
                            <td>{{ bugs.severity }}</td>
                            <td>{{ bugs.level }}</td>
                            {% if authority != 'user' %}
                                <td>{{ bugs.difficult }}</td>
                            {% endif %}
                            <td>{{ bugs.description }}</td>
                            <!--# 创建时间-->
                            <td>{{ bugs.create_time | date:"Y-m-d H:i:s" }}</td>
                            <!--# 预计完成时间-->
                            <td>{{ bugs.estime | date:"Y-m-d " }}</td>

                            <!--# 完成时间-->
                            {% if bugs.state == '已完成' %}
                                <td>{{ bugs.success_time | date:"Y-m-d H:i:s" }}</td>
                            {% else %}
                                <td></td>
                            {% endif %}
                            <!--#　完成花费时长-->
                            {% if authority != 'user' %}
                                {% if bugs.success_time != 'null' %}
                                    <td>{{ bugs.days }}</td>
                                {% else %}
                                    <td></td>
                                {% endif %}
                            {% endif %}
                            <td>{{ bugs.owner_c_name }}</td>
                            <td>{{ bugs.owner_phone }}</td>
                            <td>{{ bugs.owner_email }}</td>
                            <td>{{ bugs.assignee_c_name }}</td>
                            <td>{{ bugs.assignee_phone }}</td>
                            <td>{{ bugs.assignee_email }}</td>
                            <td>{{ bugs.modify_bug_user }}</td>
                            <!--# 最后修改时长-->
                            <td>{{ bugs.modify_time | date:"Y-m-d H:i:s" }}</td>

                        </tr>
                    {% endfor %}

                    </tbody>
                </table>
                <!--分页-->
                <div class="pagination">
                <span class="step-links">
                    {% if bugs_message.has_previous %}<!--判断是否还有上一页-->
                        <a href="?page=1">&laquo首页</a>
                        <a href="?page={{ bugs_message.previous_page_number }}">上一页</a>
                    {% endif %}
                </span>
                    <span class="current">
                第 {{ bugs_message.number }} 页
            </span>
                    {% if bugs_message.has_next %}
                        <a href="?page={{ bugs_message.next_page_number }}">下一页</a>
                        <a href="?page={{ bugs_message.paginator.num_pages }}">尾页</a>
                    {% endif %}
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        function go(e) {
            var id = $(e)[0].id;
            e.href = '/detail_bug/' + id
        }

        function go_demand(e) {
            var id = $(e)[0].id;
            e.href = '/detail_demand/' + id
        }

        <!--bug_list和demand_list 交替显示-->
        $("#id_bug").click(function () {

            document.getElementById("t1").style.display = "block";
            document.getElementById("t2").style.display = "none";
        })
        $("#id_demand").click(function () {
            document.getElementById("t1").style.display = "none";
            document.getElementById("t2").style.display = "block";
        })

    </script>
{% endblock %}



